
<script>
	import {mapActions,mapMutations} from 'vuex'
	import config from '@/admin.config.js'
	import {version} from './package.json'
	import { uniAdminCacheKey } from './store/constants.js'
	import {handlePushMessage}  from './js_sdk/uni-id-pages/push.js'
	export default {
		created() {
			this.clear = undefined
		},
		methods: {
			...mapMutations('app',['SET_THEME']),
			...mapActions({
				init: 'app/init'
			}),
			clearPlatform() {
				const keysOfPlatform = uni.getStorageInfoSync().keys.filter(key => key.indexOf('platform') > -1)
				keysOfPlatform.length && keysOfPlatform.forEach(key => uni.removeStorageSync(key))
			}
		},
		onPageNotFound(msg) {
			uni.redirectTo({
				url: config.error.url
			})
		},
		onLaunch: function() {
			uni.onPushMessage((msg) => {
				handlePushMessage(msg)
			})
			uni.getPushClientId({
				success:function(res){
					var cid = res.cid;
					console.log('cid',cid);
					getApp().globalData.push_clientid = cid;
					var global = uniCloud.importObject('global');
					global.addOrUpdateOpendbDevice(cid).then(res=>{
					 global.addDataToUserLog({
						 type:1,
						 text:'用户push_clientid：['+cid+'],获取成功，已更新到opendb-device表，结果：'+res
					 });
					}).catch(error=>{
						global.addDataToUserLog({
							type:1,
							text:'用户push_clientid：['+cid+'],获取失败，原因：'+error
						});
					});
				},
				fail:function(error) {
					console.log('获取客户端错误',error);
				}
			})
			// // #ifdef H5
			// console.log(
			// 	`%c 你瞅你🐎呐 %c v臭.傻.B `,
			// 	'background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px;  color: #fff',
			// 	'background:#007aff ;padding: 1px; border-radius: 0 3px 3px 0;  color: #fff; font-weight: bold;'
			// )
			// // #endif
			// // #ifdef H5
			
			// 此处为强制用户必须登录才能访问其他页面，如果需要部分页面不登录也能访问，需要在此过滤这些页面不执行下面的代码或直接注释掉此代码
			let uni_id_token_expired = uni.getStorageSync("uni_id_token_expired");
			if (!uni_id_token_expired || uni_id_token_expired < Date.now()) {
				uni.reLaunch({
					url: config.login.url
				})
			}
			// #endif
			// 线上示例使用
			// console.log('%c uni-app官方团队诚邀优秀前端工程师加盟，一起打造更卓越的uni-app & uniCloud，欢迎投递简历到 hr2013@dcloud.io', 'color: red');
			console.log('App Launch')
			if (this.$uniIdPagesStore.store.hasLogin) {
				this.init()
			}

			// 登录成功回调
			uni.$on('uni-id-pages-login-success', () => {
				this.init()
			})

			// theme
			this.SET_THEME(uni.getStorageSync(uniAdminCacheKey.theme) || 'default')
		},
		onShow: function() {
			this.clear = setInterval(() => this.clearPlatform(), 15*60*1000)
		},
		onHide: function() {
			this.clear && clearInterval(this.clear)
		}
	}
</script>

<style lang="scss">
	.telApp{
		font-size:12px;
		color:#999;
	}
	.TelApp{
		/* 创建线性渐变背景 */
		  background-image: linear-gradient(to top, #908d86,#22211f);
		  /* 设置文本颜色为透明 */
		  color: transparent;
		  /* 裁剪背景至文本形状 */
		  background-clip: text;
		  /* 允许背景裁剪 */
		  -webkit-background-clip: text;
		  -webkit-text-fill-color: transparent;
		  /* 其他样式，例如字体大小、行高等 */
		font-family: Helvetica, "Trebuchet MS", Verdana, sans-serif;
		font-weight: bold;
	}
	.pages_content{
		 overflow: hidden; /* 超出部分隐藏 */
		text-overflow: ellipsis; /* 使用省略号代替被截断的文本*/
		display: -webkit-box; /* 将元素作为弹性伸缩盒子 */
		-webkit-line-clamp:1; /* 最多显示两行 */
		-webkit-box-orient: vertical; /* 设置弹性伸缩盒子的子元素垂直排列 */
	}
	.underlineApp{
		color:#0c3ddd;
		cursor:pointer;
		text-decoration-color:#36d ;
		font-weight:400;  text-decoration: underline;
	}
	.labelApp{
		font-size:13px;
		color:#989898;
		font-family: Helvetica, "Trebuchet MS", Verdana, sans-serif;
	}
	.fontColorApp{
		 /* 创建线性渐变背景 */
		  background-image: linear-gradient( 185deg, #ff5d00, #dd9f01);
		  /* 设置文本颜色为透明 */
		  color: transparent;
		  /* 裁剪背景至文本形状 */
		  background-clip: text;
		  /* 允许背景裁剪 */
		  -webkit-background-clip: text;
		  -webkit-text-fill-color: transparent;
		  /* 其他样式，例如字体大小、行高等 */
		font-family:  serif;
		font-weight: bold;
	}
	.titleApp{
		font-weight: bold;
		color:#5f5f5f;
		font-family: '黑体', 'Microsoft YaHei', '微软雅黑'
	}
	.pagetitle {
		padding: 10rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.right {
			display: flex;
		}
	}
	.textApp{
		font-family: "隶书";
	}
	.textApp2{
		font-family: "楷体", "宋体",serif;
	}
	.textApp3{
		/* 创建线性渐变背景 */
		  background-image: linear-gradient(to top, #7a7872,#22211f);
		  /* 设置文本颜色为透明 */
		  color: transparent;
		  /* 裁剪背景至文本形状 */
		  background-clip: text;
		  /* 允许背景裁剪 */
		  -webkit-background-clip: text;
		  -webkit-text-fill-color: transparent;
		  /* 其他样式，例如字体大小、行高等 */
			font-family: "新宋体", "宋体",serif;
			font-weight: bold;
	}
	
	#outsideDiv::-webkit-scrollbar {
	   /* 竖置滚动条 宽度 */
	   width: 8px;
	   /* 横置滚动条 高度 */
	   height:13px;
	}
	/*正常情况下滑块的样式--滑块颜色*/
	#outsideDiv::-webkit-scrollbar-thumb {
	   background-color: rgba(119, 101, 99, 0.3);
	   border-radius: 1px;
	   -webkit-box-shadow: inset 1px 1px 0 rgba(0, 0, 0, .1);
	}
	/*放在滑块上的颜色*/
	#outsideDiv::-webkit-scrollbar-thumb:hover {
	   background-color: rgba(173, 173, 173, 0.8);
	   -webkit-box-shadow: inset 1px 1px 0 rgba(0, 0, 0, .1);
	}
	/*正常时候的主干部分 //滚动条初始化颜色*/
	#outsideDiv::-webkit-scrollbar-track {
	   border-radius: 1px;
	   -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0);
	   background-color: rgba(239, 239, 239, 0.89);
	}
	/*鼠标悬浮在滚动条上的主干部分*/
	#outsideDiv::-webkit-scrollbar-track:hover {
	   background-color: rgba(255, 0, 0, 0.1);
	}
	@import "@/static/iconfont/iconfont.css";
	@import '@/common/uni.css';
	@import '@/common/uni-icons.css';
	@import '@/common/admin-icons.css';
	@import '@/common/theme.scss';
	@import '@/static/css/global.css';
</style>
